﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class invoice : System.Web.UI.Page
{

    List<Bestlife.ERP.Entities.Cart_Item> shp = new List<Bestlife.ERP.Entities.Cart_Item>();
    Bestlife.ERP.BusinessRules.Shopping_Cart shoppingCheck;
    Boolean transact_Ok = false;
    string invoiceids = "";
    string uid = "0";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {

            Bestlife.ERP.DataAccess.ReturncountForRecipt rsp = new Bestlife.ERP.DataAccess.ReturncountForRecipt();

            string invoiceids = rsp.ReturnReciptID().ToString();
            string invoiceNo = "BC" + invoiceids;
            InvNo.Text = invoiceNo;
            Date.Text = System.DateTime.Now.Day.ToString() + "/" + System.DateTime.Now.Month.ToString() + "/" + System.DateTime.Now.Year.ToString();
            string uid = Session["user"].ToString();
            //string uid = "7";
            Bestlife.ERP.Entities.E_Profile pro = Bestlife.ERP.DataAccess.DistributerAC.getallprofileinfo(uid);
            ID.Text = "BLAA"+uid;
            Name.Text = pro.Title1 + pro.Name1;

            //#region
            //Bestlife.ERP.DataAccess.parents pa = new Bestlife.ERP.DataAccess.parents();
            ////get parent
            //if (!uid.Equals("1"))
            //{
            //    String Parent_1 = pa.parent(uid);
            //    Bestlife.ERP.Entities.E_Profile profl = Bestlife.ERP.DataAccess.DistributerAC.getallprofileinfo(Parent_1);
            //    sup_user.Text = "BLAA" + Parent_1;
            //    sup_uname.Text = profl.Title1 + profl.Name1;
            //}
            //else 
            //{
            
            //}
            //#endregion

            reBind();
        }
        catch (Exception) 
        { 
        
        }
    }

    #region Rebind

    public void reBind()
    {
        List<Bestlife.ERP.Entities.Return_to_R> listrtn = new List<Bestlife.ERP.Entities.Return_to_R>();
        List<Bestlife.ERP.Entities.Tocheck_To_cart> listrtntocheck = new List<Bestlife.ERP.Entities.Tocheck_To_cart>();
        listrtn.Clear();
        listrtntocheck.Clear();
        if (Session["cart"] != null)
        {
            shoppingCheck = (Bestlife.ERP.BusinessRules.Shopping_Cart)Session["cart"];

            TotAmount.Visible = false;
            totpv.Visible = false;
            totbv.Visible = false;
            if (shoppingCheck.Items.Count > 0)
            {
                TotAmount.Visible = true;
                totpv.Visible = true;
                totbv.Visible = true;

                #region to recipt
                listrtn = shoppingCheck.reciptvalues;
                GridView1.DataSource = listrtn;
                GridView1.DataBind();


                TotAmount.Text = "Rs." + shoppingCheck.total;
                totpv.Text = "" + shoppingCheck.totalPoint_value;
                totbv.Text = "" + shoppingCheck.totalBusiness_Value;
                Label3.Text = "Rs." + shoppingCheck.Tot_discounttot;
                Label1.Text = "Rs." + shoppingCheck.total_Rprice;
                Label2.Text = "" + shoppingCheck.total_quantity;


                #endregion

            }
        }
    }
    #endregion


    protected void Button1_Click(object sender, EventArgs e)
    {
        HttpContext.Current.Response.Redirect("backtoshopingwithend.aspx");
    }
}